package com.glela.sensitiveWords.beans;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by liujie 
 */
public class Node implements Serializable {
    /**
	 * 
	 */
	private static final long serialVersionUID = 7451598705708361949L;
	private Map<String, Node> children = new HashMap<>(0);
    private boolean isEnd = false;

    public Node() {}

    public Node addChar(char c) {
        String cStr = String.valueOf(c);
        Node node = (Node) this.children.get(cStr);
        if (node == null) {
            node = new Node();
            this.children.put(cStr, node);
        }
        return node;
    }

    public Node findChar(char c) {
        String cStr = String.valueOf(c);
        return (Node) this.children.get(cStr);
    }

    public boolean getIsEnd() {
        return this.isEnd;
    }

    public Map<String, Node> getChildren() {
        return children;
    }

    public void setChildren(Map<String, Node> children) {
        this.children = children;
    }

    public void setIsEnd(boolean isEnd) {
        this.isEnd = isEnd;
    }
}
